# 异常

try:
    print(5/0)
except ZeroDivisionError:
    print('you can not divide by zero')

print(type(1.5))

print("Give me two numbers, and I'll divide them.")
print("Enter 'q' to quit.")

# 依赖于try代码块成功执行的代码都应放到else代码块中:
while True:
    first_number = input("\nFirst number: ")
    if first_number == 'q':
        break
    second_number = input("Second number: ")
    if first_number == 'q':
        break
    try:
        answer = float(first_number) / float(second_number)
    except ZeroDivisionError:
        print("You can't divide by 0!")
    except ValueError:
        pass
    else:
        print(answer)

filename = 'alice.txt'
try:
    with open(filename) as f_obj:
        contents = f_obj.read()
except FileNotFoundError:
    msg = 'sorry,' + filename  +' file not exist'
    print(msg)


